//
//  PlayerViewController.m
//  Golf
//
//  Created by mrbradle on 11/30/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "PlayerViewController.h"


@implementation PlayerViewController

@synthesize player,nameLabel,actionLabel,cards,x,y,knocked;

+ (int)WIDTH { return 96; }
+ (int)HEIGHT { return 64; }

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)updatePlayer:(GolfPlayer*)player_; {
    self.player = player_;
    self.nameLabel.text = player.name;
}

- (id)initWithPlayer:(GolfPlayer*)player_ x:(int)x_ y:(int)y_ {
    self.player = player_;
    self.x = x_;
    self.y = y_;
    return self;
}

- (void)dealloc
{
    [super dealloc];
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle


// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
    UIView* view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, [PlayerViewController WIDTH], [PlayerViewController HEIGHT])];
    //view.backgroundColor = [UIColor redColor];
    self.view = view;
}



// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
    [super viewDidLoad];
    
    self.nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.x+10, self.y, [PlayerViewController WIDTH]-20, 20)];
    self.nameLabel.textAlignment = UITextAlignmentCenter;
    self.nameLabel.font = [UIFont fontWithName:@"Arial" size:10];
    self.nameLabel.text = player.name;
    [self.view addSubview:nameLabel];
    
    self.actionLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.x+15, self.y+20, [PlayerViewController WIDTH]-30, 20)];
    self.actionLabel.textAlignment = UITextAlignmentCenter;
    self.actionLabel.font = [UIFont fontWithName:@"Arial" size:10];
    self.actionLabel.text = @"";
    self.actionLabel.textColor = [UIColor colorWithRed:1 green:0 blue:0 alpha:1];
    [self.view addSubview:actionLabel];
    
}


- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end
